import os

from pydantic import Field
from pydantic_settings import BaseSettings
from pydantic_settings import SettingsConfigDict

os.environ["metrics__bedrock_namespace"]="app bedrock_namespace in env"


class MetricsSettings(BaseSettings):
    bedrock_namespace: str = Field(default=...)
    aws_region: str = Field(default=...)

class Settings(BaseSettings):
    model_config = SettingsConfigDict(
        env_nested_delimiter="__", # 嵌套属性分割标记
        env_file="./.env",  # 指定配置文件路径
        extra='allow' # 是否允许多余参数读入
    )

    app_name: str = Field(default=...)
    metrics: MetricsSettings | None = None

settings = Settings()
print(settings.app_name)
print(settings.metrics.bedrock_namespace)
print(settings.metrics.aws_region)